<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
      function checkInp() {
          let inpObj = document.getElementById("inp");
          let val = inpObj.value;
          alert(val);
      }
     </script>
</head>
<body>
<input type="text" id="inp" value="tom" /><br />
<input type="button" value="校验输入的值" onclick="checkInp()"/>
</body>
</html>